import Vue from 'vue';
// import Page2 from "./components/Home.vue";
// import MainContent from "./components/MainContent.vue";
// import BookDetail from "./components/BookDetail.vue";
// import MainDetail from "./components/MainDetail.vue";
// import Home from "./components/Home.vue";
// import Index from "./components/Index.vue";
// import SearchBox from "./components/SearchBox.vue";
// import VueRouter from "vue-router";
// import Router from 'vue-router'
import Router from 'vue-router'

const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)

export default new Router({
    routes: [
        // 以 / 开头的嵌套路径会被当作根路径
        // {
        //     path: "/home",
        //     component: Home,
        //     name: "Home",
        //     children: []
        // },
        {
            path: '/Home',
            name: 'Home',
            component: () =>
                import ( /* webpackChunkName: "home" */ './components/common/Home.vue'),
            children: [
                {
                    path: '/NewEbookSearch',
                    name: 'NewEbookSearch',
                    component: () =>
                        import ( /* webpackChunkName: "NewEbookSearch" */ './components/page/NewEbookSearch/NewEbookSearch.vue'),
                    meta: { title: '新电子书检索' },
                },{
                    path: '/EbookSearch',
                    name: 'EbookSearch',
                    component: () =>
                        import ( /* webpackChunkName: "EbookSearch" */ './components/page/EbookSearch/EbookSearch.vue'),
                    meta: { title: '电子书检索' },
                },
                {
                    path: '/BookSearch',
                    name: 'BookSearch',
                    component: () =>
                        import ( /* webpackChunkName: "booksearch" */ './components/page/BookSearch/BookSearch.vue'),
                    meta: { title: '统一检索' },
                },
                {
                    path: '/PaperbookSearch',
                    name: 'PaperbookSearch',
                    component: () =>
                        import ( /* webpackChunkName: "paperbooksearch" */ './components/page/PaperbookSearch/PaperbookSearch.vue'),
                    meta: { title: '纸书检索' },
                },

                {
                    path: '/QikanSearch',
                    name: 'QikanSearch',
                    component: () =>
                        import ( /* webpackChunkName: "QikanSearch" */ './components/page/QikanSearch/QikanSearch.vue'),
                    meta: { title: '电子期刊检索' },
                },
            ]
        },

        {
            path: "/QikanrBookDetail",
            component: () =>
                import ( /* webpackChunkName: "BookDetail" */ './components/page/QikanSearch/BookDetail.vue'),
            name: "QikanBookDetail",
            meta: { title: '期刊详情' },
        },
        {
            path: "/EBookDetail",
            component: () =>
                import ( /* webpackChunkName: "BookDetail" */ './components/page/EbookSearch/BookDetail.vue'),
            meta: { title: '电子书详情' },
        },
        {
            path: "/NewEBookDetail",
            component: () =>
                import ( /* webpackChunkName: "BookDetail" */ './components/page/NewEbookSearch/NewBookDetail.vue'),
            meta: { title: '新电子书详情' },
        },
        {
            path: "/PBookDetail",
            component: () =>
                import ( /* webpackChunkName: "BookDetail" */ './components/page/PaperbookSearch/BookDetail.vue'),
            meta: { title: '纸书详情' },
        },
        // {
        //     path: "/QikanSearch",
        //     component: MainContent,
        //     name: "QikanSearch",
        //     children: [
        //         { path: "/BookInfo/:id", component: MainContent, name: "BookInfo" },
        //     ]
        // },
        // {
        //     path: "/BookSearch",
        //     component: MainContent,
        //     name: "BookSearch",
        //     children: [
        //         { path: "/BookInfo/:id", component: MainContent, name: "BookInfo" },
        //     ]
        // },
        // {
        //     path: "/PaperbookSearch",
        //     component: MainContent,
        //     name: "PaperbookSearch",
        //     children: [
        //         { path: "/BookInfo/:id", component: MainContent, name: "BookInfo" },
        //     ]
        // },
        // {
        //     path: "/EbookSearch",
        //     component: MainContent,
        //     name: "EbookSearch",
        //     children: [
        //         { path: "/BookInfo/:id", component: MainContent, name: "BookInfo" },
        //     ]
        // },
        // {
        //     path: "/QikanSearch",
        //     component: MainContent,
        //     name: "QikanSearch",
        //     children: [
        //         { path: "/BookInfo/:id", component: MainContent, name: "BookInfo" },
        //     ]
        // },
        // {
        //     path: "/detail",
        //     component: () =>
        //         import ( /* webpackChunkName: "BookDetail" */ './components/BookDetail.vue'),
        //     name: "detail",
        // },
        // { path: "/Index", component: Index, name: "Index" },

        // 通配符 * 会匹配所有路径
        // 路由 { path: '*' } 通常用于客户端 404 错误
        // 含有通配符的路由应该放在最后
        { path: "*", redirect: { name: "EbookSearch" } }
    ]
});